﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MaLu.Data;
using System.Data;
using MaLu.Common;
using System.Xml;
using MaLu.BusiLogic;
using MaLu.Framework.Common;

namespace MaluJg.web.Visite
{
    public partial class item3v : VisitePage1
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {


                if (VisiteID != Guid.Empty)
                {

                    DataTable dt = SqlHelper.Instance.ExecuteDataTable(Provider, "select * from Visite where id ='" + VisiteID.ToString() + "'");
                    if (dt.Rows.Count > 0)
                    {
                        //lbLeader.Text = dt.Rows[0]["Leader"].ToString();
                        lbDept2.Text = dt.Rows[0]["Interviewee"].ToString();
                        lbYear.Text = dt.Rows[0]["Year"].ToString();
                        lbMonth.Text = dt.Rows[0]["Month"].ToString();

                    }
                }
                BindData();
            }
        }
        private void BindData()
        {
            string projectname = string.Empty;
            string content = BLVisite.GetVisiteItem(Provider, VisiteID, "item3.aspx", ref projectname);
            if (content != string.Empty)
            {
                XmlDocument document = new XmlDocument();
                document.LoadXml(content);
                XmlElement xe = document.SelectSingleNode("//记录人") as XmlElement;
                tbRecord.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//单位") as XmlElement;
                tbDept1.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//月1") as XmlElement;
                tbMonth1.Text = Util.ReturnXml(xe.InnerText);

                xe = document.SelectSingleNode("//年2") as XmlElement;
                tbYear2.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//月2") as XmlElement;
                tbMonth2.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//日2") as XmlElement;
                tbDay2.Text = Util.ReturnXml(xe.InnerText);
                xe = document.SelectSingleNode("//问题") as XmlElement;

                XmlNodeList xnl = xe.ChildNodes;
                if (xnl.Count >= 1)
                {
                    tbP00.Text = xnl[0].Attributes["n"].Value;
                    tbP01.Text = xnl[0].Attributes["d"].Value;
                }

                if (xnl.Count >= 2)
                {
                    tbP10.Text = xnl[1].Attributes["n"].Value;
                    tbP11.Text = xnl[1].Attributes["d"].Value;
                }

                if (xnl.Count >= 3)
                {
                    tbP20.Text = xnl[2].Attributes["n"].Value;
                    tbP21.Text = xnl[2].Attributes["d"].Value;
                }

                if (xnl.Count >= 4)
                {
                    tbP30.Text = xnl[3].Attributes["n"].Value;
                    tbP31.Text = xnl[3].Attributes["d"].Value;
                }

                if (xnl.Count >= 5)
                {
                    tbP40.Text = xnl[4].Attributes["n"].Value;
                    tbP41.Text = xnl[4].Attributes["d"].Value;
                }

                if (xnl.Count >= 6)
                {
                    tbP50.Text = xnl[5].Attributes["n"].Value;
                    tbP51.Text = xnl[5].Attributes["d"].Value;
                }

                if (xnl.Count >= 7)
                {
                    tbP60.Text = xnl[6].Attributes["n"].Value;
                    tbP61.Text = xnl[6].Attributes["d"].Value;
                }

                if (xnl.Count >= 8)
                {
                    tbP70.Text = xnl[7].Attributes["n"].Value;
                    tbP71.Text = xnl[7].Attributes["d"].Value;
                }

            }
        
        }
     
    }
}
